package com.wy.powerbuilder.mapper.hxl;

import com.github.pagehelper.PageInfo;
import com.wy.powerbuilder.entity.hxl.carcontract;
import com.wy.powerbuilder.entity.hxl.carseat;
import com.wy.powerbuilder.entity.lwg.owner;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface carcontractMapper {

    //分页查询
    PageInfo<carcontract> selByPage(Integer pageNo, Integer pageSize);

    //查询车位合同表
    List<carcontract> carsele(String c_userName,String c_contractid);
    //查询车位
    @Select("select * from carseat where cs_state='空闲'")
    List<carseat> carseatsAll();
    //添加合同
    @Insert("INSERT INTO carcontract VALUES (null,#{c_userName},#{c_contractid}, #{c_number}, #{c_carNumber}, #{c_date},#{c_endDate},#{c_goodcost},#{c_type},#{c_signdate},'已生效',#{c_phone})")
    int addcarcontract(carcontract st);
    //修改车位状态
    @Update("UPDATE carseat SET  cs_state='已售' where cS_number=#{cS_number}")
    int update(String cS_number);
    //修改车位状态
    @Update("UPDATE carseat SET  cs_state='空闲' where cS_number=#{cS_number}")
    int destroy(String cS_number);
    //修改合同状态
    @Update("UPDATE carcontract SET c_state='已作废' WHERE c_contractid=#{c_contractid}")
    int compact(String c_contractid);
    //删除合同
    @Delete("delete from carcontract where c_id=#{c_id}")
    int deletedestroy(Integer c_id);

    //查询空闲车位
    @Select("SELECT COUNT(*) FROM carseat  WHERE cs_state='空闲'")
    int sele();
    //查询已售车位
    @Select("SELECT COUNT(*) FROM carseat  WHERE cs_state='已售'")
    int selel();
    //查询全部车位
    @Select("SELECT COUNT(*) FROM carseat")
    int selek();
    //查询合同已生效
    @Select("SELECT COUNT(*) FROM carcontract  WHERE c_state='已生效'")
    int selem();
    //查询合同已作废
    @Select("SELECT COUNT(*) FROM carcontract  WHERE c_state='已作废'")
    int selems();
    //查询全部合同
    @Select("SELECT COUNT(*) FROM carcontract ")
    int selema();

}
